package HLLib.userControl.HLPanelPickUp;

import javax.microedition.lcdui.Image;

import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLImage;
import HLLib.base.HLScreen;
import HLLib.control.HLPanel;
import HLLib.control.HLTextPageOld;
import HLLib.userControl.defalut.HLBundle;

public class HLDesPanel extends HLPanel {

    public static final int OFFSET_X = 3;

    public static final int OFFSET_Y = 6;

    int xText;

    public int selectColor = 0xffff00;

    public int color = 0xffecf3fd;

    Image img;

    HLImage icon;

    public Object data;

    public HLTextPageOld textPage;

    public HLDesPanel(Image img, Object data) {
        HLBundle bundle = (HLBundle) data;
        this.data = bundle.getData("data");
        this.img = img;
        tabelStop = true;
        textPage = new HLTextPageOld(HLLib.base.HLScreen.width - OFFSET_X * 2 - 20);
        textPage.textColor = 0xff000000;
        textPage.SetText1(bundle.getString("name"));

        height = HLGraphics.StringHeight() + OFFSET_Y * 2;
        dock = DOCK_STYLE_TOP;
        width = HLScreen.width;

    }

    public void AdjustSize() {
        if (parent != null) {
            parent.AdjustSize();
        }
    }

    public void Logic() {

        super.Logic();
        if (IsFocus()) {
            RefreshEvent(GetScreenX(), GetScreenY(), GAME_BUTTON_ACTION);
        }
    }

    public void Refresh() {
        super.Refresh();

    }

    public void Render(HLGraphics g) {
        // super.Render(g);
        int screenX = GetScreenX();
        int screenY = GetScreenY();
        g.FillRect(screenX, screenY, width, height, 0xffffff);
        if (IsFocus()) {
            g.FillRect(screenX, screenY, width, height, HLPanelGroup.SELECTED_COLOR);// d0d9f2);//0xd0ebf2);
            g.DrawImage(new HLImage(img), screenX + width - img.getWidth() - 5, screenY + (height - img.getHeight() >> 1), HLGraphics_H.TRANS_NONE);
        } else {

        }
        xText = OFFSET_X;
        int offsetX = screenX + xText;
        int offsetY = screenY + OFFSET_Y;

        textPage.Render(g, offsetX, offsetY);
    }

}
